import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '编号',
    align: "center",
    dataIndex: 'no',
  },
  {
    title: '照片',
    align: "center",
    dataIndex: 'picturesList',
    width: 140,
    slots: { customRender: 'img' },
  },
  {
    title: '视频',
    align: "center",
    dataIndex: 'video'
  },
  {
    title: '日期',
    align: "center",
    dataIndex: 'date',
    customRender: ({ text }) => {
      return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
    },
  },
  {
    title: '拍照人',
    align: "center",
    dataIndex: 'photographer'
  },
  {
    title: '生长周期',
    align: "center",
    dataIndex: 'growthcycleId_dictText'
  },
  {
    title: '种植计划',
    align: "center",
    dataIndex: 'growPlanId'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "编号",
    field: 'no',
    component: 'Input'
  },
  {
    label: "拍照人",
    field: 'photographer',
    component: 'Input'
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'no',
    component: 'Input',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入编号!' },
      ];
    },
  },
  {
    label: '照片',
    field: 'pictures',
    component: 'InputTextArea',
    dynamicRules: ({ model, schema }) => {
      return [
        { required: true, message: '请输入照片' },
      ];
    },
  },
  {
    label: '视频',
    field: 'video',
    component: 'InputTextArea',
  },
  {
    label: '日期',
    field: 'date',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      placeholder: '请选择日期',
    },
  },
  {
    label: '拍照人',
    field: 'photographer',
    component: 'Input',
  },
  {
    label: '生长周期id',
    field: 'growthcycleId',
    component: 'Input',
  },
  {
    label: '种植计划id',
    field: 'growPlanId',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[] {
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}
